/*
 * Copyright 2020, GeoSolutions Sas.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree.
 */

// **************
// Theme
// **************

#gn-components-theme(@theme-vars) {
    .gn-resource-card {
        .color-var(@theme-vars[main-color]);
        .background-color-var(@theme-vars[main-bg]);
        .card-img-top {
            .color-var(@theme-vars[image-color]);
            .background-color-var(@theme-vars[image-bg]);
        }
        .card-title a {
            .color-var(@theme-vars[main-color]);

            &:hover {
                text-decoration: underline;
            }
        }

        &.active {
            .border-color-var(@theme-vars[focus-color]);
            .outline-color-var(@theme-vars[focus-color]);
        }

        &:not(.read-only):hover {
            .border-color-var(@theme-vars[focus-color]);
        }
        .gn-card-options, .gn-card-view-editor {
            .color-var(@theme-vars[main-color]);
            .background-color-var(@theme-vars[main-bg]);
        }
        .gn-card-options {
            .border-color-var(@theme-vars[main-border-color]);
        }
        .card-img-placeholder {
            .background-color-var(@theme-vars[main-bg]);
            .color-var(@theme-vars[primary]);
        }
    }
    .gn-unadvertised {
        .color-var(@theme-vars[warning])
    }
}

// **************
// Layout
// **************

.gn-resource-card {
    .shadow-sm();
    transition: box-shadow, border 0.3s;
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    word-wrap: break-word;
    background-clip: border-box;
    border: 1px solid rgba(0,0,0,.125);
    border-radius: .25rem;

    &:hover { 
        .card-resource-list .gn-resource-status:last-child {
            margin-right: 2rem;
            transition: all 0.2s;
        }
        .gn-resource-action-buttons {
            .gn-card-options:not(.open) {
                opacity: 1;
            }
        }
    }

    .gn-resource-card-link {
        position: absolute;
        width: 100%;
        height: 100%;
    }

    .gn-featured-card-title {
        font-weight: bold;
    }

    .gn-card-title {
        font-weight: normal;
    }

    .gn-footer-wrapper {
        position: relative;
        min-height: 30px;
        pointer-events: none;
    }

    .gn-card-footer {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        bottom: 0.1rem;
    }

    .gn-card-user {
        flex: 1;
        margin: 0;
    }

    .gn-card-actions{
        display: flex;
    }

    .gn-card-options{
        margin: 0.25rem 0.5rem 0.25rem 0;
    }

    .gn-card-view-editor{
        margin: 0.25rem 0;

        
    }

    .gn-card-view-editor-right{
        margin: 0.25rem;
    }

    .gn-card-options, .gn-card-view-editor  {

        .dropdown-menu {
            min-width: 8rem;
        }
        .dropdown-item {
            padding: 0.25rem 1.0rem;
        }
    }

    .gn-card-view-editor {
        margin-bottom: 0.4rem;
    }

    .gn-card-options .dropdown-toggle::after {
        display: none;
    }
    .gn-card-options,
    a {
        pointer-events: auto;
    }
    .gn-card-view-editor{
        span{
            margin: 0 0.2rem;
        }
        a {
            font-size: 0.75rem;
        }
    }
    .gn-resource-card-body-wrapper {
        flex: 1;
        display: flex;
        flex-direction: column;
    }
    .card-body {
        position: relative;
        pointer-events: none;
        z-index: 2;
        flex: 1 1 auto;
        min-height: 1px;
        padding: 0.5rem;

        .gn-card-description {
            margin-bottom: 0.25rem;
        }
    }
    .card-img-top {
        width: 100%;
        height: 160px;
        object-fit: cover;
    }
    .gn-resource-card-category {
        text-transform: uppercase;
    }
    .card-title,
    .card-text {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        &.list {
            white-space: unset;
            max-height: 2.2rem;
            &+.ellipsis {
                position: absolute;
                bottom: 0.625rem;
            }
        }
        .gn-spinner {
            margin-right: 0.4rem;
        }
    }
    .card-title {
        font-size: 0.875rem;
        margin-bottom: .75rem;
        display: flex;
        justify-content: space-between;
        align-items: center;

        div:first-of-type {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .fa {
            margin: 0;
            margin-right: 0.4rem;
        }

        .fa-info-circle {
            margin-right: 0;
        }

        a {
            &:hover {
                text-decoration: underline;
            }
        }
    }
    .card-text {
        font-size: 0.69rem;
    }
    .card-text:last-child {
        margin-bottom: 0;
    }

    .gn-tag {
        padding: 0;
        margin: 0;
        font-size: inherit;
        &:hover {
            color: inherit;
            opacity: 0.8;
            background-color: transparent;
        }
    }
    &.active {
        outline-width: 0.25rem;
        outline-style: solid;
        .shadow();
    }
    &:not(.read-only):hover {
        .shadow();
    }
    &.deleted {
        opacity: 0.4;
    }
    .card-resource-list {
        display: flex;
        flex: 1 1 auto;
        .card-img-left{
            width: 160px;
            height: 135px;
            object-fit: cover;
        }
        .gn-resource-card-body-wrapper {
            width: 20vw;
        }
    }
}

.gn-card-author-image {
    width: 15px;
    height: 15px;
    object-fit: cover;
    border-radius: 50%;
    margin-right: 0.25rem;
}

.gn-resource-action-buttons {
    position: absolute;
    top: 0;
    right: 0;

    .gn-card-options {
        transition: all .2s ease-in-out;
        border-radius: 2px;

        &:not(.open) {
            opacity: 0;
        }

        &.open {
            opacity: 1;
        }

    }
}

button.btn.btn-default.gn-resource-status.gn-status-button {
    padding: 0;
    pointer-events: auto;
    &:hover, &:active, &:focus {
        background-color: transparent;
        border-color: transparent;
        -webkit-box-shadow: unset;
        box-shadow: unset;
    }
}

.card-img-placeholder {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3rem;
}

@media screen and (min-width: 1649px) {
    .gn-resource-card {
        .card-resource-list {
            .gn-resource-card-body-wrapper {
                width: 10vw;
            }
        }
    }
}

.gn-unadvertised {
    cursor: pointer;
    pointer-events: auto;
}